package com.hong.spring.datasource.config;


import org.apache.commons.dbcp.BasicDataSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.sql.DataSource;


/**
 * @Auther: csh
 * @Date: 2020/8/13 11:44
 * @Description:java实现dbcp的配置
 */
@Configuration
public class DbcpConfig {
    /**
     *
     * 功能描述:通过代码实现
     *
     * @param:
     * @return:
     * @auther: csh
     * @date: 2020/8/13 14:26
     */
    @Bean
    public DataSource dataSource() {
        BasicDataSource ds = new BasicDataSource();
        ds.setDriverClassName("com.mysql.jdbc.Driver");
        ds.setUrl("jdbc:mysql://localhost:3306/spring?useUnicode=true&characterEncoding=utf-8");
        ds.setUsername("root");
        ds.setPassword("123456");
        return ds;
    }
}
